<?php
/**
 * Created by PhpStorm.
 * User: lijie
 * Date: 2018/10/31
 * Time: 20:09
 */
namespace app\reserve\model;

use think\Model;

class Withdraw extends Model{

    protected $table = "orange_withdraw";
    protected $autoWriteTimestamp = true;
    protected $createTime = "ctime";
    protected $updateTime = "utime";
    protected $dateFormat;

    /**
     * Notes:  添加提现
     * Create Date: 2018/10/31
     * Create by :lijie
     */
    public function addWith($param)
    {
        return $this->isUpdate(false)->allowField(true)->save($param);
    }

    /**
     * Notes:  编辑提现
     * Create Date: 2018/10/31
     * Create by :lijie
     */
    public function editWith($param,$where)
    {
        return $this->isUpdate(true)->allowField(true)->save($param,$where);
    }

    /**
     * Notes:  提现列表
     * Create Date: 2018/10/31
     * Create by :lijie
     */
    public function selectWith($where,$pagenum,$listNum)
    {
        return $this->alias("w")
                    ->where($where)
                    ->field("w.*,c.name cash_name")
                    ->join("__CASH__ c","w.a_id = c.a_id")
                    ->order("w.ctime desc")->page($pagenum,$listNum)->select();
    }

    /**
     * Notes:  提现详情
     * Create Date: 2018/10/31
     * Create by :lijie
     */
    public function findWith($where)
    {
        return $this->where($where)->find();
    }
}